Skip to content

[rocprofiler-compute] Default PC sampling sort to count, add --pc-sampling-rows#7763

Merged
vedithal-amd merged 6 commits into
rocprofiler-compute-developfrom
users/vedithal-amd/pc-sampling-rows-default-count
Jun 26, 2026
Merged

[rocprofiler-compute] Default PC sampling sort to count, add --pc-sampling-rows#7763
vedithal-amd merged 6 commits into
rocprofiler-compute-developfrom
users/vedithal-amd/pc-sampling-rows-default-count

Conversation

@vedithal-amd

@vedithal-amd vedithal-amd commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Motivation

End users analyzing PC sampling mostly care about the top hotspots. Defaulting the sort to count surfaces the most-sampled instructions first, and a new --pc-sampling-rows option keeps the table from flooding the CLI by default while letting users widen it as needed.

Technical Details

  • Changed --pc-sampling-sorting-type default from offset to count, and restricted it to choices offset or count so invalid values fail fast at argparse.
  • Added --pc-sampling-rows analyze option (default 10); 0 shows all rows. Negative values are rejected by the argparse validator.
  • Row limit is applied in the shared loader after sorting, so both CLI and Web UI honor it.

JIRA ID

AIPROFCOMP-681

Test Plan

  • Run unit tests: tests/test_argparser.py, tests/test_pc_sampling_analysis.py, tests/test_analyze_commands.py.
  • Verify analyze output: default shows top 10 by count; --pc-sampling-rows 0 shows all; --pc-sampling-sorting-type offset still sorts by offset.

Test Result

Unit tests pass locally (199 passed). Ruff clean.

Submission Checklist

…pling-rows

- Default --pc-sampling-sorting-type to count so the analysis table
  leads with the most-sampled instructions (hotspots).
- Add --pc-sampling-rows analyze option (default 10) to cap the PC
  sampling table; 0 or negative shows all rows.

Co-Authored-By: Claude Opus 4 (1M context)
@github-actions github-actions Bot added documentation Improvements or additions to documentation project: rocprofiler-compute labels Jun 24, 2026
- Validate --pc-sampling-rows as non-negative; 0 shows all rows.
- Clarify the 0-means-all behavior in help text, code comment, and docs.

Co-Authored-By: Claude Opus 4 (1M context)
- Merge the per-option PC sampling analyze tests into one function.
- Assert the negative-rejection message via a mocked stderr instead of
  capsys.

Co-Authored-By: Claude Opus 4 (1M context)
…rror

- Assert argparse raises by mocking ArgumentParser.error instead of
  capturing stderr.

Co-Authored-By: Claude Opus 4 (1M context)
- Drop the bespoke fixture and fold the num_rows cases into one
  parametrized test over the existing helper.

Co-Authored-By: Claude Opus 4 (1M context)
@vedithal-amd vedithal-amd marked this pull request as ready for review June 24, 2026 18:29
@vedithal-amd vedithal-amd requested review from a team and prbasyal-amd as code owners June 24, 2026 18:29
Copilot AI review requested due to automatic review settings June 24, 2026 18:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates rocprofiler-compute’s PC sampling analysis defaults to better surface hotspots by default, and introduces a new row-limit option to keep CLI output manageable while ensuring consistent behavior across CLI and Web UI.

Changes:

  • Defaulted --pc-sampling-sorting-type from offset to count.
  • Added --pc-sampling-rows (default 10) and applied row limiting after sorting in the shared loader.
  • Updated docs/changelog and expanded unit tests to cover the new defaults and row limiting.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
projects/rocprofiler-compute/src/utils/parser.py Adds num_rows support and applies row limiting after sorting in the shared PC sampling loader.
projects/rocprofiler-compute/src/argparser.py Changes default sorting to count and introduces --pc-sampling-rows with validation.
projects/rocprofiler-compute/tests/test_pc_sampling_analysis.py Adds coverage for num_rows limiting behavior and updates args used by non-metrics table tests.
projects/rocprofiler-compute/tests/test_argparser.py Adds coverage for default/override behavior of the new analyze options and validation of --pc-sampling-rows.
projects/rocprofiler-compute/docs/how-to/pc_sampling.rst Documents new default sorting and the new --pc-sampling-rows option.
projects/rocprofiler-compute/CHANGELOG.md Records the new option and the changed default sorting behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread projects/rocprofiler-compute/src/utils/parser.py Outdated
Comment thread projects/rocprofiler-compute/src/argparser.py
Comment thread projects/rocprofiler-compute/src/argparser.py

@cfallows-amd cfallows-amd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please add two of the suggestions from copilot- update PR description to match implementation for negative error vs all, and the "choices" in argparser to add rigidity when specifying sort type. Marking approved since these are straightforward changes

Comment thread projects/rocprofiler-compute/src/utils/parser.py Outdated
…ard num_rows

Add choices=[offset, count] so invalid sort types fail fast at argparse
instead of a later runtime error. Guard the num_rows slice against negative
values passed programmatically so the public loader behaves like "show all".

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@vedithal-amd vedithal-amd merged commit a676e94 into rocprofiler-compute-develop Jun 26, 2026
22 checks passed
@vedithal-amd vedithal-amd deleted the users/vedithal-amd/pc-sampling-rows-default-count branch June 26, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants